package com.fangmou.ing.util;

/**
 * Created by IntelliJ IDEA.
 * User: liming
 * Date: 2010-4-11
 * Time: 18:44:15
 * To change this template use File | Settings | File Templates.
 */
public class StringUtils {
    /**
     * 忽略前导空白和尾部空白（包括换行、制表符）
     * 字符串为null时返回""
     * @param str
     * @return
     */
    public static String trim(String str) {
        if (str == null) {
            return "";
        }
        int start = 0;
        int end = str.length();
        for (int i = start; i < end; i++) {
            char c = str.charAt(i);
            if (c == 65279 || c < 32) {
                start = i;
            } else {
                break;
            }
        }
        return str.substring(start).trim();
    }
}
